package com.hyuk.hyukfgw.util.excp;

import lombok.Getter;

/**
 * <h1>业务异常类。</h1><br/>
 *
 * @author hmilyylimh
 * ^_^
 * @version 0.0.1
 * ^_^
 * @date 2022-02-18
 */
@Getter
public class FgwException extends RuntimeException {

    /** <h2>异常码</h2> **/
    private String excpCode;

    /** <h2>异常描述</h2> **/
    private String excpMemo;

    public FgwException() {
        this(FgwCodeEnum.SYSTEM_EXCEPTION);
    }

    public FgwException(String message) {
        this(FgwCodeEnum.SYSTEM_EXCEPTION, message);
    }

    public FgwException(Throwable cause) {
        this(FgwCodeEnum.SYSTEM_EXCEPTION, cause);
    }

    public FgwException(String excpCode, String message) {
        super("[" + excpCode + "]" + message);
        this.excpCode = excpCode;
        this.excpMemo = message;
    }

    public FgwException(String message, Throwable cause) {
        this(FgwCodeEnum.SYSTEM_EXCEPTION.getCode(), FgwCodeEnum.SYSTEM_EXCEPTION.getMsg() + ":" + message, cause);
    }

    public FgwException(String excpCode, String message, Throwable cause) {
        super("[" + excpCode + "]" + message, cause);
        this.excpCode = excpCode;
        this.excpMemo = message;
    }

    public FgwException(FgwCodeEnum fgwCodeEnum) {
        super("[" + fgwCodeEnum.getCode() + "]" + fgwCodeEnum.getMsg());
        this.excpCode = fgwCodeEnum.getCode();
        this.excpMemo = fgwCodeEnum.getMsg();
    }

    public FgwException(FgwCodeEnum fgwCodeEnum, String extraMsg) {
        super("[" + fgwCodeEnum.getCode() + "]" + fgwCodeEnum.getMsg() + ":" + extraMsg);
        this.excpCode = fgwCodeEnum.getCode();
        this.excpMemo = fgwCodeEnum.getMsg() + ":" + extraMsg;
    }

    public FgwException(FgwCodeEnum fgwCodeEnum, Throwable cause) {
        super("[" + fgwCodeEnum.getCode() + "]" + fgwCodeEnum.getMsg(), cause);
        this.excpCode = fgwCodeEnum.getCode();
        this.excpMemo = fgwCodeEnum.getMsg();
    }

    public FgwException(FgwCodeEnum fgwCodeEnum, String extraMsg, Throwable cause) {
        super("[" + fgwCodeEnum.getCode() + "]" + fgwCodeEnum.getMsg() + ":" + extraMsg, cause);
        this.excpCode = fgwCodeEnum.getCode();
        this.excpMemo = fgwCodeEnum.getMsg() + ":" + extraMsg;
    }
}